package com.flowerplus.store.common.data.utils.ui;

import android.os.Build;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.view.View;
import android.view.WindowManager;

/**
 * Created by z on.
 * Des:
 * Date: 2017/3/7
 */

public class BottomSheetUtil {

    /**
     * 展开
     *
     * @param v
     */
    public static void collapsedDialog(View v) {
        View parent = (View) v.getParent();
        if (parent == null) return;
        BottomSheetBehavior<View> from = BottomSheetBehavior.from(parent);
        from.setState(BottomSheetBehavior.STATE_COLLAPSED);
    }

    /**
     * 设置dialog状态栏为透明
     *
     * @param bottomSheetDialog
     */
    public static void statusBarTranslucent(BottomSheetDialog bottomSheetDialog) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            bottomSheetDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    }

}
